# 执行main方法
import argparse
from datetime import datetime
from DataService import DataService


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--phone", help="Phone number")
    parser.add_argument("--regTime", help="Registration time")
    args = parser.parse_args()
    
    phone = ""
    if args.phone is None:
        print("Phone number is required")
        return
    else:
        phone = args.phone
    
    regTime = ''
    if args.regTime is None:
        regTime = datetime.now().strftime('%Y%m%d%H%M%S')
    
    print("Phone number: " + phone, ", Registration time: " + regTime)
    # phone = "18321277411";
    # regTime = "2024011818";
    dataService = DataService();
    dataService.get_apply_key();
    requestXml = dataService.create_xml(phone, regTime, "BAA11");
    
    opendata_url = "http://kfpttest.supnumber.cn:9011/cap/dataservice/appDataServiceAuthen.proxy"
    responseXml = dataService.do_post(opendata_url, requestXml)
    print(responseXml)
    
if __name__ == '__main__':
    main()